<?php if(!IS_AJAX){?>
<include file="Public:header" />
<script src="__PUBLIC__/Intesys/AdminX/js/jquery.nicescroll.js"></script>
<style>
    .sourceInput{ max-width:60px; margin-bottom:5px;}
    .sourcePanel{text-align: center;position: absolute;top: 30px;background: #fafafa;border: 1px solid #ddd;padding: 5px; display:none; z-index:3; min-width:110px;}
    .missionform {box-shadow: 0;}
    .formBox{ min-height:160px;}
    .checkoutform .form-inline{ position:relative; padding-left:10px;}
    .checkoutform .checkbox-inline{ padding-top:9px;}
    .checkoutform .form-inline .groupName{ min-width:80px; border-right:1px dotted; padding-right:5px;}
    .checkoutform .form-inline:nth-child(2n){ background-color:rgba(255,255,255,1);border:1px solid #DDDDDD;}
    .checkoutform .form-inline:nth-child(2n-1){ background-color:rgba(0,0,0,0.02);}
    .checkoutform .cover{ width:100%; height:100%; display:none; background:rgba(0,0,0,0.2); position:absolute; top:0; left:0;}
    .checkoutform .sourceEdit{outline: 1px dashed;outline-offset: -6px; transition:all 0.2s ease-in-out;}
    .checkoutform .sourceEdit:hover{ background:rgba(0,0,0,0.03); outline-style:dotted;}
    .groupName{border-right:none!important;}
	
	.table tbody tr td{vertical-align: middle;}
	.sort{display:inline-block;height:20px;width:20px;vertical-align: middle;}

    .directory-info-row .social-links li span{
        background: #EFF0F4;width:25px;height:25px;line-height:25px;text-align:center;display:inline-block;border-radius:50%;
        -webkit-border-radius: 50%;color: #7A7676;cursor:pointer;
    }
    /*.clearp{margin:0;padding:0;}*/
    .pass-span{display:inline-block;text-align:right;width:100%;line-height:40px;}
    .integral-num{display:inline-block; width:50px;height:24px;padding:6px;}
    .table-bordered>thead>tr>th{border-bottom:none;background: linear-gradient(to bottom,#fdfdfd 30%,#e9e9e9);}
    .formBox.a{background:url(__PUBLIC__/a.png) no-repeat center center; background-size:50% auto;}
	.formBox.p{background:url(__PUBLIC__/p.png) no-repeat center center; background-size:50% auto;}
	
    .social-links li span:hover{background-color:#65cea7; color:#fff;}

	.selectlist{margin:0; padding:0;}
	.selectlist ul{padding:0}
	.selectlist li{list-style-type:none; margin:0; padding:0;padding:5px; border-bottom:1px solid #eee; margin:0 8px;}
	.selectlist li:hover{background:#eee;}
	
	.social-links li span:active{ background:#7A7676; color:#fff;}
    @media screen and (max-width: 1100px) {
        .divfloat {
            	text-align: left!important;
        }
        .schedulescroll{
            height:auto!important;
            max-height: 210px;
        }
    }
	.text-orange{color:#f60;}
	
	.a{ cursor:pointer;}
	.limit_h{ height:36px; overflow:hidden; margin-top:6px;}
	/*审批列表*/
	.panel-none{ background-color:#fff; box-shadow:0 1px 4px rgba(0,0,0,0.14); line-height:40px;}
	.panel-list{ border:2px solid transparent; transition:border ease-in-out 0.2s;}
	.panel-list:hover,.panel-list.hover{ border-color:#47b3ff;}
	.panel-list .status{ display:inline-block; padding:5px; border:1px solid #eee; margin-right:5px; margin-bottom:5px;}
	.box-avatar{ padding-left:70px; position:relative;}
	.dir-info .dir-like{ margin-top:12px; color:inherit;}
	.box-detail .text-muted{white-space: nowrap;text-overflow: ellipsis;overflow: hidden;}
	.avatar{ position:absolute; left:10px; top:0;}
	.pagesBox{ height:inherit;}
	.pagesBox > div,.pagesBox > nav{ padding-top:10px; padding-bottom:10px;}
	.pagination{ margin:0;}
	/*审批详细面板*/
	.panel-detail{width: 40%;height: 100%;position: fixed; left:100%;z-index: 4; bottom:0; padding-top:120px;display:none;}
	.panel-detail .panel-footer{ position:absolute;}
	.panel-detail .detail-footer{position: absolute;bottom: 52px;left: 0; background:white; padding-top:10px; padding-bottom:10px;}
	.panel-detail .btn-sm{ width:25%; margin:0 10px;}
	.panel-detail hr{ margin-top:10px; margin-bottom:10px;}
	.panel-detail .info>p{ display:table;}
	.panel-detail .info>p>:first-child{ display:table-cell; min-width:70px;}
	.panel-extended .row{ line-height:34px; white-space:nowrap;}
	.detail-main{background: #fff; box-shadow: 0 10px 23px 2px rgba(0,0,0,.2), 0 3px 6px rgba(0,0,0,.15); height:100%;}
	.cover{position:fixed; left:0; top:0; width:100%; height:100%; display:none; z-index:3}
	/*审批详细的审核列表*/
	.block-list{ background:#f4f4f4; line-height:30px; padding:10px; margin-bottom:15px;}
	.block-list>div{ padding-left:5px; padding-right:5px;}
	.divfloat span{ font-size:12px;}
</style>
    <div class="row" style="margin-top:-15px">
        <div class="panel affixelement" style="z-index:3;"  afftop="0" >
            <div class="panel-body">
                <div class="icheck">
                    <form action="<?php echo U('index');?>" id="newajaxlistboxform" style="background:#fff; ">
                        <input type="hidden" name="state" value="all">
                        <input type="hidden" name="type" value="0">
                        <input type="hidden" name="sorttype" value="">
                        <div class="pull-left" style="line-height:34px;padding-top:5px" id="missioncountbox"></div>
                        <div class="btn-group" style="padding-top:5px;">
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button">
                                <span class="dropdown-text">选择时间 </span><span class="caret"></span>
                            </button>
                            <ul role="menu" class="dropdown-menu">
                                <li style="white-space:nowrap" class="row">
                                    <div class="col-xs-12 text-center dropdown-form">
                                        <input class="form-control datepicker" id="starttime" name="starttime" readonly style="cursor:pointer; width:120px; display:inline;height:35px" value="<?php echo $sttime; ?>" placeholder="起始时间" type="text">
                                        至
                                        <input class="form-control datepicker" id="endtime" name="endtime" readonly style="cursor:pointer; width:120px; display:inline;" value="<?php echo $edtime; ?>" placeholder="结束`时间" type="text">
                                        <i class="fa icon-times text-danger a f-clearDate btn btn-link" style="display:none;"></i>
                                    </div>                                        
                                </li>
                            </ul>
                        </div>
                        <div class="input-group" style="width:170px;padding-top:5px">
                            <input type="text" name="keywords" value="<?php echo $keywords; ?>"  placeholder="审批名称或姓名" class="form-control" style="height:35px">
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-default" style="height:35px"><i class="fa icon-search"></i></button>
                            </span>
                        </div>
                        <html:dropdownselect class="typeselect" selected="" name="type" style="height:30.99px; width:110px;margin-top:5px" multi="0" action="{:U('Team/form')}" title="选择审批分类"  placeholder="选择审批分类"  listloaded="listloaded" />
                        <div id="reselectlayout" style="top:0; display:none; left:0; bottom:0; right:0; position:fixed; z-index:4999;"></div>
                        <div id="ajaxlistboxboc" style="display:none;"> 
                            <a href="##" class="btn btn-info" id="ajaxlistboxsa"> 全选 </a> 
                            <a href="##" class="btn btn-info" id="ajaxlistboxca"> 全不选 </a> 
                            <a href="##" class="btn btn-info" id="ajaxlistboxsar"> 反选 </a> 
                            <a rel="{:U('pass')}" href="##" class="btn btn-success"> 通过 </a> 
                        </div>
                        <!-- 右边 -->
                        <!--<div class="btn-group pull-right" style="padding-top:5px;">
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"><i class="fa icon-list "></i> <span class="caret"></span></button>
                            <ul id="listcheck" role="menu" class="dropdown-menu">
                                <li>
                                    <a onclick="location.href='{:U('index',['type'=>'0'])}'" href="javascript:void(0);"><i class="fa icon-list "></i> 列表视图</a>
                                </li>
                                <li>
                                    <a onclick="location.href='{:U('index',['type'=>'1'])}'" href="javascript:void(0);"><i class="fa icon-th"></i> 表格视图</a>
                                </li>
                            </ul>
                        </div>-->
                        <!-- 右边结束 -->
                        <div style="float:none; clear:both;"></div>
                    </form>
                </div>
            </div>
            <form id="missioncountboxform" data-action="{:U('missioncount')}" action="{:U('missioncount')}"></form>
        </div>
        <div class="col-sm-12 box-detail">
            <div id="masonrybox1"></div>
            <div id="newajaxlistbox" >
                <?php    }?>
                <!-- 数据主体 -->
                <?php if(IS_AJAX){?>
                <volist name="list" id="vo" key="i">
                	<!--审批列表-->
                    <div id="obj-{$vo.id}" onClick="showmore({$vo.id})" class="panel panel-list">
                        <div class="panel-body">
                            <div class="row">
                                <div class="dir-info">
                                    <div class="col-xs-5">
                                    	<!--<div class="avatar">
                                            <img src="/Public/timg.jpg" alt="">
                                        </div>-->
                                        <h5>
                                        	{$vo.proposername}—{$vo.title}
                                        	<?php if(!empty($vo['formcategory_name'])){ ?><span class="text-muted">（{$vo.formcategory_name}）</span><?php } ?>
                                        </h5>
                                        <div class="text-muted"><small>
                                        	<?php echo empty($vo['formtemplateText'])?'暂无内容':str_replace('rn','',$vo['formtemplateText']) ?>
                                        </small></div>
                                    </div>
                                    <div class="col-xs-2 text-success">
                                        <div class="dir-like">
                                        	 <volist name="vo['integral']" id="rvo">
                                                <volist name="rvo['integral']" id="ivo">
                                                    <b>{$InteTypeList[$key]} </b><span class="text-orange"> {$ivo} </span>
                                                </volist>
                                            </volist>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <div class="scheStatus-{$vo.id} limit_h"></div>
                                    </div>
                                    <div class="col-xs-2 text-danger">
                                        <div class="dir-like obj-status">
                                        	<switch name="vo.state" >
                                                <case value="0"><span style="color:#D9534F;">已驳回</span></case>
                                                <case value="1">待审核</case>
                                                <case value="2">处理中</case>
                                                <case value="3"><span style="color:#6BC5A4;">已通过</span></case>
                                                <default />待递交
                                            </switch>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--审批详细面板-->
                    <div class="panel-detail" id="detail-{$vo.id}">
                    	<div class="detail-main">
                            <div class="panel-heading">{$vo.title}<a onClick="showmore();" href="javascript:;" class=" pull-right text-success"><i class="fa icon-times"></i></a></div>
                            <div class="panel-body">
                                <div class="info">
                                	
                                    <p class="col-xs-6 pull-right">
                                    	<span style="display:inline;">审批状态：</span>
                                        <span>
                                            <switch name="vo.state" >
                                                <case value="0"><span style="color:#D9534F;">已驳回</span></case>
                                                <case value="1">待审核</case>
                                                <case value="2">处理中</case>
                                                <case value="3"><span style="color:#6BC5A4;">已通过</span></case>
                                                <default />待递交
                                            </switch>
                                        </span>
                                    </p>
                                    <p>
                                    	<span>申请人：</span>
                                        <span>{$vo.proposername}</span>
                                    </p>
                                    <p>
                                    	<span>申请时间：</span>
                                        <span>{$vo.createtime|date='Y-m-d H:i',###}</span>
                                    </p>
                                    <p class="text-table">
                                        <span>内容：</span>
                                        <span class="text-muted">{:empty($vo['formtemplateText'])?'暂无内容':replacebr($vo['formtemplateText'])}</span>
                                    </p>
                                    <?php if(!empty($vo['integral'])){ ?>
                                    <p>
                                    	<span>积分：</span>
                                        <span>
                                            <volist name="vo['integral']" id="rvo">
                                                <volist name="rvo['integral']" id="ivo">
                                                    <span>{$InteTypeList[$key]}</span><b class="text-orange"> {$ivo} </b>
                                                </volist>
                                            </volist>
                                        </span>
                                    </p>
                                    <?php } ?>
                                    <div>
                                        <hr/>
                                        <span>审批人： </span> 
                                        <span> {$vo.approvername}</span>
                                        <hr/>
                                    </div>
                                </div>
                                <?php 
                                	//审批记录样式配置
                                    $vo['approvername']=str_replace('，',',',$vo['approvername']);
                                	$arrApprover=array_flip(explode(',',$vo['approvername']));
                                	$faIcon=['<i class="fa icon-times text-danger"></i>','<i class="fa icon-check text-success"></i>','<i class="fa icon-ban text-warning"></i>']; 
                                ?>
                                <div class="row mission">
                                    <div class="schedulebox col-lg-12 col-sm-12 schedulescroll" id="schedulebox-{$vo.id}" style="padding:0;padding-bottom:5px;margin-bottom:10px;display:inline-block;height:220px;background-color:#fff;overflow-x:hidden;overflow-y:auto;">
                                    <notempty name="vo['schedule']">
                                        <volist name="vo['schedule']" id="s" key="y">
                                            <div >
                                                <div class="block-list">
                                                	<div class="col-sm-2">{$s.membername}</div>
                                                    <div class="col-sm-2 divfloat text-muted">
                                                        <gt name="s['sendParent']" value="0"><span >已递交上级</span></gt>
                                                        <eq name="s['status']" value="0"><span style="color:#d9534f">已驳回</span></eq>
                                                        <eq name="s['status']" value="1"><span style="color:#3c763d;">已通过</span></eq>
                                                    </div>
                                                    <div class="col-sm-3">
                                                        <div class="clearp text-muted" title="{$s.comment}"><notempty name="s['comment']">{$s.comment}<else/>无意见</notempty></div>
                                                    </div>
                                                    <div class="col-sm-3 divfloat text-muted">
                                                        <span class="clearp">
                                                        <notempty name="s.integrals">
                                                            <volist name="s['integrals']" id="rvo">
                                                                {$InteTypeList[$rvo['type']]} : 
                                                                <b class="text-orange">{$rvo.num}</b>分　
                                                            </volist>
                                                        </notempty>
                                                        	<span class="hidden">
                                                            	<gt name="s['ticketnum']" value="0">奖票:<span class="text-orange">{$s.ticketnum}</span></gt>
                                                            </span>
                                                        </span>
                                                    </div>
                                                    <div class="col-sm-2 text-muted divfloat">
                                                        <span class="clearp">{:date('Y-m-d', $s['datatime'])}</span>
                                                    </div>
                                                    <div class="clearfix"></div>
                                                    <script>
                                                        <?php  unset($arrApprover[$s['membername']]); ?>
                                                        $(".scheStatus-{$vo.id}").append('<div class="status">{$faIcon[$s['status']]} {$s.membername}</div>');
                                                    </script>
                                                </div>
                                            </div>
                                            
                                        </volist>
                                        
                                        <else/>
                                        <div style="padding:5px; text-align:center;padding-bottom:10px;"> 暂无审批记录 </div>
                                    </notempty>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                
                            </div>
                            <?php if($vo['state']!=3&&$vo['state']!=0){ ?>
                            <footer class="panel-footer text-center">
                                <a class="btn btn-success btn-sm" href="#window" onClick="_openWindow('{:U('mymissionread', array('id' => $vo['id']))}', 650, '{$vo.title}(修改)', '确认', null, '');"> 修改</a> 
                              <eq name="vo['state']" value="-1"> 
                                <a class="btn btn-success btn-sm" href="javascript:void(0);" onClick="mission_send({$vo.id}, this);"> 递交</a> </if>
                              </eq>
                   				<a class="btn btn-success btn-sm" href="javascript:void(0);" title="发送给其他人" onClick="_openWindow('{:U('Mission/sendTo', array('id' => $vo['id']))}', 500, '{$vo.title}(发送表格)', '发送', null, '');">发送</a> 
                  &nbsp;
                  			  <if condition="in_array($vo['state'], array(0,1,2))">
                              	<a class="btn btn-danger btn-sm" href="javascript:void(0);" onClick="mission_cancel({$vo.id}, this);"> 取消</a> 
                              </if>
                            </footer>
                            <?php } ?>
                        </div>
                    </div>
                    <script>
						//$('.schedulescroll').niceScroll({styler:"fb",cursorcolor:"#65cea7", cursorwidth: '3', cursorborderradius: '0px', background: '#424f63', spacebarenabled:false, cursorborder: '0'});
						//给审批列添加没有审批的人的标签提醒
						<?php  foreach($arrApprover as $k=>$v){ ?>
							$(".scheStatus-{$vo.id}").append('<div class="status">{$faIcon[2]} {$k}</div>');
						<?php } ?>
					</script>
                </volist>
                <!--<div onClick="showmore();" class="cover"></div>-->
            	<!-- 数据主体结束 -->
                <?php } ?>
                <?php if(!IS_AJAX){?>
            </div>
	        <div id="newajaxlistboxpages" class="pagesBox text-center panel"> <?php echo $pages;?> </div>
        </div>
    </div>
<include file="Public:script" />
<script src="__PUBLIC__/Js/jquery.masonry.min.js"></script>
<script>
	//显示/隐藏面板
    //$('#missioncountbox').ajaxlist();
	//重写一个异步提交的方法，数据来自另一个表单
	$('#missioncountboxform').submit(function(e) {
        e.preventDefault();
		var $aim=$('#'+$(this).attr('id').replace('form',''));
		var $obj=$('#newajaxlistboxform');
		$.getJSON($(this).attr('action'),$obj.serialize(),function(data){
			if(data.tbody){
				$aim.html(data.tbody);	
			}
		});
		return;
    });
	
    $('#newajaxlistbox').ajaxlist({success:function(){
		showmore();
		$("#missioncountboxform").submit();
        $('[data-toggle="tooltip"]').tooltip();
        $('.missiontable thead th').each(function(){
            $(this).attr('click','0');
            if($.session.get('myth_'+$(this).index())){
                $(this).attr('click', $.session.get('myth_'+$(this).index()));
            }
            $.session.set('myth_'+$(this).index(),'0');//先清零,防止页面出问题
            if($(this).index()>3 && $(this).index()<6){
                $(this).children('i').addClass('icon-unsorted');
                if($(this).attr('click')=='0'){
                    $(this).children('i').removeAttr('class').addClass('fa icon-unsorted');
                }else if($(this).attr('click')=='1'){
                    $(this).children('i').removeAttr('class').addClass('fa icon-sort-down');
                }else if($(this).attr('click')=='2'){
                    $(this).children('i').removeAttr('class').addClass('fa icon-sort-up');
                }
                $(this).click(function(){
                    if($(this).attr('click')=='0'){
                        $('.missiontable thead th').attr('click','0');
                        $(this).attr('click','1');
                        $.session.set('myth_'+$(this).index(),'1');//后赋值
                    }else if($(this).attr('click')=='1'){
                        $('.missiontable thead th').attr('click','0');
                        $(this).attr('click','2');
                        $.session.set('myth_'+$(this).index(),'2');
                    }else if($(this).attr('click')=='2'){
                        $('.missiontable thead th').attr('click','0');
                        $(this).attr('click','1');
                        $.session.set('myth_'+$(this).index(),'1');
                    }
                    $("#newajaxlistboxform input[name='sorttype']").val($(this).index()+'_'+$(this).attr('click'));
                    $('#newajaxlistboxform').submit();
                });
            }
        });
    }});
	
    $.cookie('loadIndexUrl', window.location.href, {path:'/'});
	
	//选择时间的控件点击事件不冒泡
	$(".btn-group .datepicker").click(function(e) {
		event.stopPropagation();
    });
	//选择时间的效果显示到面板中
    $('.icheck input').change(function(){
		//判断时间控件
		if($(this).val()&&$(this).siblings('.datepicker').val()){
			$(".dropdown-text").text($(this).val()+' 至 '+$(this).siblings('.datepicker').val()+' ')
			$(this).parent().click();
			$(".f-clearDate").show();
		}else if($(this).hasClass('datepicker')){
			return;
		}
        $('#newajaxlistboxform').submit();
		
		//$("#missioncountboxform").attr('action',$("#missioncountboxform").attr('data-action')+'&'+$('#newajaxlistboxform').serialize());
		//$("#missioncountboxform").submit();
    });
	//清除时间选择状态
	$(".f-clearDate").click(function(e) {
		$(".dropdown-text").text('选择时间');
		$(".dropdown-menu input").val('');
		$('#newajaxlistboxform').submit();
		//$("#missioncountboxform").attr('action',$("#missioncountboxform").attr('data-action'));
		//$("#missioncountboxform").submit();
        $(this).hide();
    });
    $('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' });$(window).trigger('resize');
	
	//审批提交方法
    function mission_send(id,e){
        if(!confirm('确定递交吗？')){
            return false;
        }
        hideLayer();
        $.post('{:U('send')}', {id:id}, function(data){
            if(data.status == 1){
                $('#newajaxlistboxform').submit();
                //updateList();
            }else{
                alert(data.info);
            }
        }, 'json');
    }
    function mission_cancel(id,e){
        if(!confirm('确定取消吗？')){
            return false;
        }
        hideLayer();
        $.post('{:U('cancel')}', {id:id}, function(data){
            if(data.status == 1){
                $('#newajaxlistboxform').submit();
                //updateList();
            }else{
                alert(data.info);
            }
        }, 'json');
    }
    function setstate(state){
        //reloadmasonry();
        $('#newajaxlistboxform').find('input[name="state"]').val(state);
        $('#newajaxlistboxform').submit();
    }
	
	function showmore(id){
		var $obj=$('.panel-detail.show');
		var $box=$(".box-detail");
		if(!$obj.is(":animated")){
			$('div.hover').removeClass('hover');
			if($obj.attr('id')=='detail-'+id||$('#detail-'+id).length==0){
				$box.css('width','100%');
				$obj.css({left:'100%'}).hide().removeClass('show');
			}else{
				$box.css('width','100%');
				$('.panel-detail').css({left:'100%'}).hide().removeClass('show');
				$box.filter(':not(:animated)').css({width:'58%'});
				$('#detail-'+id).filter(':not(:animated)').show().animate({left:'60%'},'fast','swing').addClass('show');
				$(".cover").show();
				$('#obj-'+id).addClass('hover');
			}
		}
	}
    function listloaded(){
        $('.typeselect').blur(function(){
            $("#newajaxlistboxform input[name='formcategory_id']").remove();
            if($('div.typeselect span.itemspan').children("input:eq(1)").length!=0){
                $('#newajaxlistboxform').append("<input type='hidden' name='formcategory_id' value='"+$('.typeselect .itemspan').children("input:eq(1)").attr('value')+"'>");
            }
            $('#missioncountbox').submit();
            //$('#newajaxlistboxform').submit();
        });
    }
</script>
</body></html><?php }?>